package beautiful.butterfly.drds.datasource.connection_contexts.mock;

import beautiful.butterfly.drds.datasource.connection_contexts.api.IConnectionContext;
import beautiful.butterfly.drds.datasource.connection_contexts.api.IParameterizedISql;
import beautiful.butterfly.drds.datasource.connection_contexts.api.IRowDataMapList;

import java.math.BigDecimal;
import java.sql.*;

public class ParameterizedSql extends Sql implements IParameterizedISql {
    private IConnectionContext connectionContext;
    private PreparedStatement preparedStatement;

    public ParameterizedSql(IConnectionContext connectionContext, PreparedStatement preparedStatement) {
        super(connectionContext, preparedStatement);
        this.connectionContext = connectionContext;
        this.preparedStatement = preparedStatement;

    }

    public IConnectionContext getConnectionContext() {
        return this.connectionContext;
    }

    public Statement getStatement() {
        return this.preparedStatement;
    }

    public void close() throws SQLException {

    }

    //


    //
    public void addBatch() throws SQLException {
        this.preparedStatement.addBatch();
    }

    public int[] executeBatch() throws SQLException {
        return this.preparedStatement.executeBatch();
    }

    //
    public void setNull(int parameterIndex, int sqlType) throws SQLException {
        this.preparedStatement.setNull(parameterIndex, sqlType);
    }

    public void setBoolean(int parameterIndex, boolean x) throws SQLException {
        this.preparedStatement.setBoolean(parameterIndex, x);
    }

    public void setShort(int parameterIndex, short x) throws SQLException {
        this.preparedStatement.setShort(parameterIndex, x);
    }

    public void setInt(int parameterIndex, int x) throws SQLException {
        this.preparedStatement.setInt(parameterIndex, x);
    }

    public void setLong(int parameterIndex, long x) throws SQLException {
        this.preparedStatement.setLong(parameterIndex, x);
    }

    public void setFloat(int parameterIndex, float x) throws SQLException {
        this.preparedStatement.setFloat(parameterIndex, x);
    }

    public void setDouble(int parameterIndex, double x) throws SQLException {
        this.preparedStatement.setDouble(parameterIndex, x);
    }

    public void setString(int parameterIndex, String x) throws SQLException {
        this.preparedStatement.setString(parameterIndex, x);
    }

    public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException {
        this.preparedStatement.setBigDecimal(parameterIndex, x);
    }

    public void setDate(int parameterIndex, Date x) throws SQLException {
        this.preparedStatement.setDate(parameterIndex, x);
    }

    public void setTime(int parameterIndex, Time x) throws SQLException {
        this.preparedStatement.setTime(parameterIndex, x);
    }

    public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
        this.preparedStatement.setTimestamp(parameterIndex, x);
    }

    public void setObject(int parameterIndex, Object x) throws SQLException {
        this.preparedStatement.setObject(parameterIndex, x);
    }

    public ParameterMetaData getParameterMetaData() throws SQLException {
        return this.preparedStatement.getParameterMetaData();
    }

    public void clearParameters() throws SQLException {
        this.preparedStatement.clearParameters();
    }

    //
    public int executeUpdate() throws SQLException {
        return this.preparedStatement.executeUpdate();
    }

    public IRowDataMapList executeQuery() throws SQLException {
        ResultSet resultSet = this.preparedStatement.executeQuery();
        IRowDataMapList rowDataMapList = new RowDataMapList(this, resultSet);

        return rowDataMapList;
    }

    //
    public ResultSetMetaData getResultSetMetaData() throws SQLException {
        return this.preparedStatement.getMetaData();
    }

    //


}
